package cn.xie.blog.model.common.enums.login;

import lombok.Data;

/**
 * @author: xiaoxie
 * create: 2025-04-21 21:39
 * @BelongsProject: blog-parent
 * @BelongsPackage: cn.xie.blog.model.common.enums.login
 * description: 登录方式枚举
 */
public enum LoginTypeEnum {

    ACCOUNT_PASSWORD(1, "账号密码登录"),
    WECHAT(2, "微信登录"),
    QQ(3, "QQ登录");

    private final Integer code;
    private final String message;

    LoginTypeEnum(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    // 根据code获取枚举
    public static LoginTypeEnum getEnumByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (LoginTypeEnum loginTypeEnum : LoginTypeEnum.values()) {
            if (code.equals(loginTypeEnum.getCode())) {
                return loginTypeEnum;
            }
        }
        return null;
    }
}
